<html>
<head><meta charset="utf-8"><title>MaybeUninit and FFI · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html">MaybeUninit and FFI</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172049358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172049358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DutchGhost <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172049358">(Jul 30 2019 at 15:40)</a>:</h4>
<p>Out of interest, I took a look at <a href="https://github.com/seanmonstar/num_cpus/blob/master/src/lib.rs" target="_blank" title="https://github.com/seanmonstar/num_cpus/blob/master/src/lib.rs">https://github.com/seanmonstar/num_cpus/blob/master/src/lib.rs</a> .<br>
I noticed a couple of <code>mem::uninitialized()</code> and <code>mem::zeroed()</code> calls, and wondered why MaybeUninit isn't used instead.</p>
<p>One answer I could come up with is that MaybeUninit isn't FFI - safe, but Im not sure. Could anyone clarify if it is FFI - safe, and if there are any niches like "Its just as FFI safe as the T it holds inside"?</p>
<p>(also, are the uses of <code>mem::uninitialized()</code> and <code>mem::zeroed()</code> sound in num_cpu's? or should they switch asap?)</p>



<a name="172054304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172054304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172054304">(Jul 30 2019 at 16:42)</a>:</h4>
<blockquote>
<p>I noticed a couple of mem::uninitialized() and mem::zeroed() calls, and wondered why MaybeUninit isn't used instead.</p>
</blockquote>
<p>Is that code older than 2 weeks ? If so, then the answer is probably that MaybeUninit was not available in stable or did not even exist when that code was written.</p>



<a name="172054343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172054343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172054343">(Jul 30 2019 at 16:43)</a>:</h4>
<p>The code appears to be 2 years old.</p>



<a name="172054360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172054360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172054360">(Jul 30 2019 at 16:43)</a>:</h4>
<p>So the answer is probably that MaybeUninit did not exist when that code was written.</p>



<a name="172056906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172056906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DutchGhost <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172056906">(Jul 30 2019 at 17:12)</a>:</h4>
<p>It could be, although there was a commit last month.<br>
Anyway, I made a pr for it.</p>



<a name="172063239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172063239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172063239">(Jul 30 2019 at 18:25)</a>:</h4>
<blockquote>
<p>also, are the uses of mem::uninitialized() and mem::zeroed() sound in num_cpu's?</p>
</blockquote>
<p>the ones for <code>zeroed</code> are likely fine, I guess <code>cpu_set_t</code> is just an integer type.<br>
the ones for <code>uninitialized</code> are not fine under the current strict rules.</p>



<a name="172106302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172106302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172106302">(Jul 31 2019 at 07:55)</a>:</h4>
<blockquote>
<p>It could be, although there was a commit last month.</p>
</blockquote>
<p>You can right click on the line on github and click on "blame", it shows that some of the lines you mention where last modified 2 years ago.</p>
<blockquote>
<p>Anyway, I made a pr for it.</p>
</blockquote>
<p>Using MaybeUninit will bump the minimum supported Rust version to the latest one, which is a major semver breaking change and means that the package won't be buildable on Debian, Ubuntu, etc. when using the system toolchain</p>



<a name="172106375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172106375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172106375">(Jul 31 2019 at 07:57)</a>:</h4>
<p>num_cpus is a super popular package, I would recommend being careful when rolling these kind of breaking changes</p>



<a name="172106859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172106859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172106859">(Jul 31 2019 at 08:04)</a>:</h4>
<blockquote>
<p>which is a major semver breaking change</p>
</blockquote>
<p>I don't think there is consensus on whether bumping the MSRV is semver-breaking or not</p>



<a name="172108806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172108806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172108806">(Jul 31 2019 at 08:38)</a>:</h4>
<p>Facts do not need consensus.</p>



<a name="172108898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172108898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172108898">(Jul 31 2019 at 08:40)</a>:</h4>
<p>I haven't seen anybody claim that bumping the MSRV does not break Rust code, and it is a claim that is trivial to refute.</p>



<a name="172109007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109007">(Jul 31 2019 at 08:42)</a>:</h4>
<p>What there is no consensus about is whether bumping the MSRV results in "acceptable" breakage and whether it should require a major semver version bump. But that has nothing to do whether the change is breaking. </p>
<p>Some people were complaining on reddit last month that their code broke because a new method was added to the standard library.</p>



<a name="172109065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109065">(Jul 31 2019 at 08:43)</a>:</h4>
<p>A lot of people were trying to explain to them that those changes are not breaking, yet most of them did not get through to those users because they were pointing out the fact that their code is correct and was compiling yesterday but does not compile today anymore.</p>



<a name="172109134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109134">(Jul 31 2019 at 08:44)</a>:</h4>
<p>Firefox was holding the latest Debian release back because it did not compile with the toolchain it was using.</p>



<a name="172109360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109360">(Jul 31 2019 at 08:47)</a>:</h4>
<p>Our non-breaking changes policies aren't really policies about what are breaking changes and what are not. They are policies about which code we are ok with breaking. That does not mean that changes break no code, and bumping num_cpus to the latest released Rust version to fix undefined behavior would mean that Ubuntu, Debian, etc. cannot package that version of the crate because it does not compile with their toolchains. So if you wanted to make a big impact by fixing undefined behavior, doing it in such a way that cannot be distributed achieves very little short term.</p>



<a name="172109436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109436">(Jul 31 2019 at 08:48)</a>:</h4>
<blockquote>
<p>Facts do not need consensus.</p>
</blockquote>
<p>you are making a particular interpretation of semver here. there's nothing factual about that.</p>



<a name="172109463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109463">(Jul 31 2019 at 08:48)</a>:</h4>
<p>I think it is a perfectly reasonable stanza to say "my crate supports the latest 2 stable releases of Rust, and if a change only breaks with older compilers, that's not semver-breaking"</p>



<a name="172109490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109490">(Jul 31 2019 at 08:49)</a>:</h4>
<p>I have seen such discussions come up several times. Not everyone shares your interpretation of semver, and pretending that it is the only interpretation won't change that.</p>



<a name="172109505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109505">(Jul 31 2019 at 08:49)</a>:</h4>
<p>I didn't suggest to bump the major semver version anywhere</p>



<a name="172109551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109551">(Jul 31 2019 at 08:50)</a>:</h4>
<p>I mentioned the fact that bumping the MSRV version breaks code</p>



<a name="172109565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109565">(Jul 31 2019 at 08:50)</a>:</h4>
<p>"semver breaking" is defined as what triggers a major semver bump</p>



<a name="172109582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109582">(Jul 31 2019 at 08:50)</a>:</h4>
<p>saying something is semver breaking but doesnt cause a bump is self-contradicting</p>



<a name="172109589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109589">(Jul 31 2019 at 08:50)</a>:</h4>
<p>then I retract that, you are right that there are many interpretations about what semver means</p>



<a name="172109603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109603">(Jul 31 2019 at 08:51)</a>:</h4>
<p>I specifically said <em>semver breaking</em>, not <em>breaking</em>. Causing inference failure by implementing a new trait is also definitely "breaking" code. it is not <em>semver breaking</em> though.</p>



<a name="172109615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109615">(Jul 31 2019 at 08:51)</a>:</h4>
<p>what I meant to say is that bumping the MSRV often breaks a lot of code</p>



<a name="172109624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109624">(Jul 31 2019 at 08:51)</a>:</h4>
<p>I tried bumping the MSRV of libc crate in march to Rust 1.20</p>



<a name="172109628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109628">(Jul 31 2019 at 08:51)</a>:</h4>
<p>I had to revert the change</p>



<a name="172109632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109632">(Jul 31 2019 at 08:51)</a>:</h4>
<p>because a lot of projects broke</p>



<a name="172109641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109641">(Jul 31 2019 at 08:51)</a>:</h4>
<p>we are in 2019, and libc targets Rust 1.13.0</p>



<a name="172109658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109658">(Jul 31 2019 at 08:52)</a>:</h4>
<p>it breaks code for users of old compilers. not sure if that means the code is broken. but I agree with the gist.</p>



<a name="172109717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109717">(Jul 31 2019 at 08:52)</a>:</h4>
<p>it makes code that used to compile not compile anymore</p>



<a name="172109724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109724">(Jul 31 2019 at 08:52)</a>:</h4>
<p>with old compilers</p>



<a name="172109730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109730">(Jul 31 2019 at 08:52)</a>:</h4>
<p>you might not consider this as breaking, because old compilers</p>



<a name="172109738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109738">(Jul 31 2019 at 08:52)</a>:</h4>
<p>other people say it broke my bash script, therefore is breaking</p>



<a name="172109763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109763">(Jul 31 2019 at 08:53)</a>:</h4>
<p>I guess all I am saying is "broken" is a compiler-version-relative notion here. but in the end for a user stuck on an old compiler that doesn't help, which is why I agree with your sentiment, just not with all of your terminology.</p>



<a name="172109791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109791">(Jul 31 2019 at 08:53)</a>:</h4>
<p>calling it "semver breaking" is controversial, depends on who is doing the releases and who is consuming them, and what there opinions are</p>



<a name="172109851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109851">(Jul 31 2019 at 08:54)</a>:</h4>
<p>we do automatically check the libc crate on CI for all API semver breaking changes, and we do break semver every release</p>



<a name="172109861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109861">(Jul 31 2019 at 08:54)</a>:</h4>
<p>because it is our opinion that some changes do not break as much code as others</p>



<a name="172109898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109898">(Jul 31 2019 at 08:55)</a>:</h4>
<p>we have "technical semver breaking changes" for all changes that should technically require a semver major bump because they break some code</p>



<a name="172109899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109899">(Jul 31 2019 at 08:55)</a>:</h4>
<blockquote>
<p>we do automatically check the libc crate on CI for all API semver breaking changes, and we do break semver every release</p>
</blockquote>
<p>ever minor release, that is? or even patch release? (not sure if libc is 1.0 yet so the difference would matter)</p>



<a name="172109913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109913">(Jul 31 2019 at 08:55)</a>:</h4>
<p>and we have "non-technical breaking changes" for ones that are breaking according to the "API guidelines"</p>



<a name="172109921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109921">(Jul 31 2019 at 08:55)</a>:</h4>
<p>every patch release</p>



<a name="172109931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109931">(Jul 31 2019 at 08:55)</a>:</h4>
<p>libc does not do minor or major releases</p>



<a name="172109985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172109985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172109985">(Jul 31 2019 at 08:56)</a>:</h4>
<p>(it can't without breaking the world)</p>



<a name="172110070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172110070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172110070">(Jul 31 2019 at 08:57)</a>:</h4>
<p>there is a tool that puts two version of your crate into a third crate, and compares the typed AST of both crate versions, and produces a diff</p>



<a name="172110128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172110128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172110128">(Jul 31 2019 at 08:58)</a>:</h4>
<p>the diff includes whether the change is non-breaking, or whether it can break code, whether the breakage requires a patch version, minor version, major version bump, etc.</p>



<a name="172110136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172110136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172110136">(Jul 31 2019 at 08:58)</a>:</h4>
<p>pretty much all changes that add new items can break code for people doing glob imports, for example</p>



<a name="172110168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172110168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172110168">(Jul 31 2019 at 08:59)</a>:</h4>
<p><a href="https://github.com/rust-dev-tools/rust-semverver/" target="_blank" title="https://github.com/rust-dev-tools/rust-semverver/">https://github.com/rust-dev-tools/rust-semverver/</a> - that's the tool</p>



<a name="172112800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172112800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DutchGhost <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172112800">(Jul 31 2019 at 09:40)</a>:</h4>
<p>I didn't think about if it was a breaking change or not. I'm not the author of num_cpu's, so the author can decide what to do with the pr I made.<br>
But, isn't fixing UB somewhat allowed to be a breaking change?<br>
And people who don't have a compiler that supports MaybeUninit on stable can always use a previous version, no?</p>



<a name="172114587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172114587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172114587">(Jul 31 2019 at 10:11)</a>:</h4>
<p><span class="user-mention" data-user-id="224097">@DutchGhost</span> another way to fix the UB there might be to replace all <code>undefined</code> by <code>zeroed</code>. (I didn't check though if that is sufficient.)</p>



<a name="172145715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172145715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172145715">(Jul 31 2019 at 17:16)</a>:</h4>
<blockquote>
<p>we are in 2019, and libc targets Rust 1.13.0</p>
</blockquote>
<p>An unreasonable situation if you ask me... the number of people who still use 1.13.0 are how many?...</p>



<a name="172152748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172152748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172152748">(Jul 31 2019 at 18:28)</a>:</h4>
<p>As I said, I tried to bump libc to 1.20 or so in march, and a couple of people complained</p>



<a name="172152803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172152803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172152803">(Jul 31 2019 at 18:29)</a>:</h4>
<p>it isn't worth it for us to bump it to Rust 1.15 or something like that, because there isn't anything there that helps</p>



<a name="172152858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172152858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172152858">(Jul 31 2019 at 18:30)</a>:</h4>
<p>like, IIRC, the regex crate supports old Rust versions, because it is required to build ripgrep, which is shipped by linux distros fixed with old rust toolchains, and might still ship patches</p>



<a name="172152951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172152951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172152951">(Jul 31 2019 at 18:30)</a>:</h4>
<p>that crate depends on libc, so we can't bump libc beyond what it supports</p>



<a name="172153120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172153120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172153120">(Jul 31 2019 at 18:32)</a>:</h4>
<p>all of this might be much easier if libc could just release a breaking version</p>



<a name="172188516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172188516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172188516">(Aug 01 2019 at 03:50)</a>:</h4>
<p>I'd like the rust community to be a lot more aware of minimum rust version and that bumping it should always go with a semver version break bump as well (0.y+1 for pre-1.0, or x+1 for post 1.0, etc)</p>
<p>unfortunately, the RFC for that seems to be stalled a bit :/</p>



<a name="172198128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198128">(Aug 01 2019 at 07:28)</a>:</h4>
<p>I think that would be a desaster</p>



<a name="172198146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198146">(Aug 01 2019 at 07:29)</a>:</h4>
<p>it would basically grind the adoption of new features to a halt -- libraries tend to avoid major version bumps, for good reasons</p>



<a name="172198240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198240">(Aug 01 2019 at 07:30)</a>:</h4>
<blockquote>
<p>But, isn't fixing UB somewhat allowed to be a breaking change?</p>
</blockquote>
<p>Do you know that the behavior is undefined?</p>



<a name="172198263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198263">(Aug 01 2019 at 07:31)</a>:</h4>
<p>AFAICT the behavior is unspecified for <code>mem::uninitialized()</code>, and the behavior of that code is defined for <code>mem::zeroed()</code>. Those are repr(C) types using integers and pointers, and all bytes zeroed is a valid representaiton for them.</p>



<a name="172198283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198283">(Aug 01 2019 at 07:31)</a>:</h4>
<p>Using <code>mem::uninitialized()</code> for those types _might_ be ok, it definetely is ok with the current implementation.</p>



<a name="172198293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198293">(Aug 01 2019 at 07:31)</a>:</h4>
<blockquote>
<p>Using <code>mem::uninitialized()</code> for those types _might_ be ok, it definetely is ok with the current implementation.</p>
</blockquote>
<p>we consider it UB though</p>



<a name="172198296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198296">(Aug 01 2019 at 07:31)</a>:</h4>
<p>Where?</p>



<a name="172198298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198298">(Aug 01 2019 at 07:32)</a>:</h4>
<p>and call it out as such in e.g. the MaybeUninit docs</p>



<a name="172198343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198343">(Aug 01 2019 at 07:32)</a>:</h4>
<p>So the MaybeUninit docs makes it undefined behavior?</p>



<a name="172198347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198347">(Aug 01 2019 at 07:32)</a>:</h4>
<p>I dont really see what "unspecified" means here</p>



<a name="172198348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198348">(Aug 01 2019 at 07:32)</a>:</h4>
<p>not having decided that it is allowed makes it UB</p>



<a name="172198356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198356">(Aug 01 2019 at 07:32)</a>:</h4>
<p>Either we explicitly say that it is UB, or it is unspecified.</p>



<a name="172198395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198395">(Aug 01 2019 at 07:33)</a>:</h4>
<p>"unspecified" works for things like layout where the compiler makes <em>a</em> choice but doesnt say which. but for steps of the abstract machine, if "unspecified" means "the machine can take any step", that is equivalent to UB.</p>



<a name="172198428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198428">(Aug 01 2019 at 07:33)</a>:</h4>
<p>Whether uninitialized is a valid representation of an <code>i8</code></p>



<a name="172198485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198485">(Aug 01 2019 at 07:34)</a>:</h4>
<p>Is that a step in the abstract machine?</p>



<a name="172198498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198498">(Aug 01 2019 at 07:34)</a>:</h4>
<p>no the step(s) is "execute <code>let x: u8 = mem::uninitialized()</code>"</p>



<a name="172198506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198506">(Aug 01 2019 at 07:34)</a>:</h4>
<p>that was an example of how to use <code>mem::uninitialized()</code> in their docs for a long time</p>



<a name="172198509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198509">(Aug 01 2019 at 07:34)</a>:</h4>
<blockquote>
<p>Whether uninitialized is a valid representation of an <code>i8</code></p>
</blockquote>
<p>I see, that's how you see this. interesting.</p>



<a name="172198513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198513">(Aug 01 2019 at 07:35)</a>:</h4>
<p>that code is 2 years old</p>



<a name="172198528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198528">(Aug 01 2019 at 07:35)</a>:</h4>
<p>this might work. so far the wording we (a few people including <span class="user-mention" data-user-id="126931">@centril</span>  and me) have been using is that these things are UB until we decided that they are not</p>



<a name="172198544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198544">(Aug 01 2019 at 07:35)</a>:</h4>
<p>and you did not object to me using that wording for <a href="https://doc.rust-lang.org/nightly/nomicon/" target="_blank" title="https://doc.rust-lang.org/nightly/nomicon/">https://doc.rust-lang.org/nightly/nomicon/</a></p>



<a name="172198553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198553">(Aug 01 2019 at 07:35)</a>:</h4>
<p>I tend to think that everything is unspecified, and that if something is UB, it should be UB by design</p>



<a name="172198554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198554">(Aug 01 2019 at 07:36)</a>:</h4>
<p>and have wording and rationale for it</p>



<a name="172198598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198598">(Aug 01 2019 at 07:36)</a>:</h4>
<p>even if the wording is "we don't know what to do here, so this is UB for now"</p>



<a name="172198601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198601">(Aug 01 2019 at 07:36)</a>:</h4>
<p>that doesnt work, unless unspecified = UB</p>



<a name="172198605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198605">(Aug 01 2019 at 07:36)</a>:</h4>
<p>because then it would be a breaking change to make it UB later</p>



<a name="172198617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198617">(Aug 01 2019 at 07:36)</a>:</h4>
<p>for integers we have enough of an idea of the spec that we boiled it down to two options, so there we have the option of saying "A or B"</p>



<a name="172198619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198619">(Aug 01 2019 at 07:36)</a>:</h4>
<p>well then <code>let x: u8 = mem::uninitialized();</code> can't be UB without introducing a breaking change</p>



<a name="172198622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198622">(Aug 01 2019 at 07:37)</a>:</h4>
<p>but in other cases that we explored less, we are nowhere close so that</p>



<a name="172198630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198630">(Aug 01 2019 at 07:37)</a>:</h4>
<p>because that's the minimum the <code>mem::uninitialized</code> docs showed for it</p>



<a name="172198638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198638">(Aug 01 2019 at 07:37)</a>:</h4>
<p>you are basically saying because Rust 1.0 didnt come with a full UB spec, we cannot make anything UB as it was all just unspecified?</p>



<a name="172198645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198645">(Aug 01 2019 at 07:37)</a>:</h4>
<p>this is not C, where we claim any kind of exhaustive standard or so</p>



<a name="172198653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198653">(Aug 01 2019 at 07:37)</a>:</h4>
<p>and AFAIK in C, the "default" when the standard imposes no requirement actually is UB</p>



<a name="172198654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198654">(Aug 01 2019 at 07:37)</a>:</h4>
<p>It did come with docs</p>



<a name="172198692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198692">(Aug 01 2019 at 07:38)</a>:</h4>
<p>and those docs do show that some things work</p>



<a name="172198699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198699">(Aug 01 2019 at 07:38)</a>:</h4>
<p>yes for <code>mem::uninitialized</code> mistakes were made</p>



<a name="172198703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198703">(Aug 01 2019 at 07:38)</a>:</h4>
<p>breaking those things are breaking changes, I do think that breaking changes are OK</p>



<a name="172198719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198719">(Aug 01 2019 at 07:38)</a>:</h4>
<p>its an engineering tradeoff whether they are worth it</p>



<a name="172198735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198735">(Aug 01 2019 at 07:39)</a>:</h4>
<p>but given that we haven't really formulated anywhere what <code>let x: u8 = mem::uninitialized();</code> does, and that in the UCG there seems to be consensus that this should work or otherwise too much code would break</p>



<a name="172198742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198742">(Aug 01 2019 at 07:39)</a>:</h4>
<p>but there's tons of other open questions around deref/offset of dangling pointers, int-ptr-casts, ptr comparison, and then all the aliasing stuff of course</p>



<a name="172198746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198746">(Aug 01 2019 at 07:39)</a>:</h4>
<p>sending PRs to crates fixing that is unecessary churn</p>



<a name="172198774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198774">(Aug 01 2019 at 07:39)</a>:</h4>
<p>and it creates "myths" that those things are UB, that might survive a future RFC that says they are not</p>



<a name="172198891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198891">(Aug 01 2019 at 07:41)</a>:</h4>
<p>so sure, if <code>let x: u8 = mem::uninitialized();</code> is UB, then we should fix those now, but we should argue why that is UB, what that UB buys us, and we should not in 3 months pass an RFC that says that's ok because people from the outside would rightfully think that we have no clue what we are doing</p>



<a name="172198903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172198903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172198903">(Aug 01 2019 at 07:41)</a>:</h4>
<p>if we are changing our minds about such "basic" things every 3 months</p>



<a name="172199347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199347">(Aug 01 2019 at 07:49)</a>:</h4>
<p>(sorry had to switch buses)</p>



<a name="172199398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199398">(Aug 01 2019 at 07:50)</a>:</h4>
<blockquote>
<p>sending PRs to crates fixing that is unecessary churn</p>
</blockquote>
<p>you mean specifically for uninitialized integers?</p>



<a name="172199437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199437">(Aug 01 2019 at 07:50)</a>:</h4>
<p>I'd rather have a myth that makes people not use <code>mem::uninitialized</code> than a myth that makes them use it</p>



<a name="172199456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199456">(Aug 01 2019 at 07:50)</a>:</h4>
<p>but I see your point</p>



<a name="172199488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199488">(Aug 01 2019 at 07:51)</a>:</h4>
<p>my thinking was: if it can become UB at any point in the future, that's equivalent to already being UB from a "I want my code to keep working" perspective</p>



<a name="172199512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172199512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172199512">(Aug 01 2019 at 07:51)</a>:</h4>
<p>we should certainly encourage people to write new code using <code>MaybeUninit</code></p>



<a name="172200820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172200820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172200820">(Aug 01 2019 at 08:12)</a>:</h4>
<p>Sure, for new code I agree, but there is a lot of code already, and changing it is not only a cost, it is also an opportunity to teach people something. I fear that we waste this opportunity if we are not sure of what the semantics we want to teach are.</p>



<a name="172200854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172200854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172200854">(Aug 01 2019 at 08:13)</a>:</h4>
<p>If these PR would say "Hey, <code>let x: u8 = mem::uninitialized();</code> is "ok", but using MaybeUninit is safer and more idiomatic" I would be ok with that</p>



<a name="172200958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172200958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172200958">(Aug 01 2019 at 08:14)</a>:</h4>
<p>or even "Hey, we don't know whether <code>let x: u8 = uninitialized();</code> is going to be "ok" or not right now, it might be, but either way, using <code>MaybeUninit</code> is safer and more idiomatic anyways, so prefer that".</p>



<a name="172200974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172200974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172200974">(Aug 01 2019 at 08:14)</a>:</h4>
<p>and I'm not only thinking about PRs here, but also about clippy lints, warnings, etc.</p>



<a name="172201001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172201001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172201001">(Aug 01 2019 at 08:15)</a>:</h4>
<p>we could be liniting <code>mem::uninitialized</code> and <code>mem::zeroed</code> already, but we should do so with care of avoiding confusing users</p>



<a name="172202792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172202792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172202792">(Aug 01 2019 at 08:47)</a>:</h4>
<blockquote>
<p>or even "Hey, we don't know whether <code>let x: u8 = uninitialized();</code> is going to be "ok" or not right now, it might be, but either way, using <code>MaybeUninit</code> is safer and more idiomatic anyways, so prefer that".</p>
</blockquote>
<p>that's the message I am usually going for</p>



<a name="172202848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172202848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172202848">(Aug 01 2019 at 08:48)</a>:</h4>
<p>also see my question above, we are specifically talking about uninitialized integers here, right?</p>



<a name="172202889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172202889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172202889">(Aug 01 2019 at 08:49)</a>:</h4>
<blockquote>
<p>we could be liniting <code>mem::uninitialized</code> and <code>mem::zeroed</code> already, but we should do so with care of avoiding confusing users</p>
</blockquote>
<p>I think we should start by linting (for both <code>uninitialized</code> and <code>zeroed</code>) for types that don't allow the all-0 bit pattern -- i.e., references, <code>NonNull</code>, <code>NonZero*</code>, <code>fn</code>. That's definitely UB, and it has already repeatedly caused issues in practice.</p>



<a name="172202907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172202907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172202907">(Aug 01 2019 at 08:49)</a>:</h4>
<p>I wouldnt lint for things where the rules are still open, that seems odd</p>



<a name="172229390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DutchGhost <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229390">(Aug 01 2019 at 15:08)</a>:</h4>
<blockquote>
<blockquote>
<p>But, isn't fixing UB somewhat allowed to be a breaking change?</p>
</blockquote>
<p>Do you know that the behavior is undefined?</p>
</blockquote>
<p>From what I understand from ralf's blog <a href="https://www.ralfj.de/blog/2019/07/14/uninit.html" target="_blank" title="https://www.ralfj.de/blog/2019/07/14/uninit.html">https://www.ralfj.de/blog/2019/07/14/uninit.html</a> , is when you write <code>mem::uninitialized()</code>, and use the value as is, the compiler has the right to shoot you in the foot whenever it wants. (unless the type you create is fine being unitialized, but such types are zst's, and MaybeUninit itself currently).<br>
Correct me if I'm wrong, but that seem pretty undefined to me.</p>
<blockquote>
<p>If these PR would say "Hey, <code>let x: u8 = mem::uninitialized();</code> is "ok", but using MaybeUninit is safer and more idiomatic" I would be ok with that</p>
</blockquote>
<p>I did exactly this: <a href="https://github.com/seanmonstar/num_cpus/pull/82" target="_blank" title="https://github.com/seanmonstar/num_cpus/pull/82">https://github.com/seanmonstar/num_cpus/pull/82</a></p>
<p>Also, mem::uninitialized() will be depricated in 1.39, so eventually there will be a a kinda soft-force to switch over, sooner or later.</p>



<a name="172229816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229816">(Aug 01 2019 at 15:14)</a>:</h4>
<blockquote>
<p>the compiler has the right to shoot you in the foot whenever it wants. (unless the type you create is fine being unitialized, but such types are zst's, and MaybeUninit itself currently).<br>
Correct me if I'm wrong, but that seem pretty undefined to me</p>
</blockquote>
<p>the thing is, the compiler curently <em>won't</em> shoot you in the foot if it is an integer type</p>



<a name="172229832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229832">(Aug 01 2019 at 15:14)</a>:</h4>
<p>and there's a lot of code relying on that. old code from when there was just no other way to work with uninitialized memory.</p>



<a name="172229861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229861">(Aug 01 2019 at 15:15)</a>:</h4>
<p>now one could say that code is wrong and shouldnt have been written (like some people argued for code that has panics passing through FFI), but well, the code exists and we have to do the best we can to deal with that.</p>



<a name="172229896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229896">(Aug 01 2019 at 15:15)</a>:</h4>
<p>Whether <code>let x: u8 = mem::uninitialized()</code> <em>should</em> be UB is being discussed at <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/71" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/71">https://github.com/rust-lang/unsafe-code-guidelines/issues/71</a></p>



<a name="172229961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229961">(Aug 01 2019 at 15:16)</a>:</h4>
<p>and my personal position is that no, it should not be UB. (this has changed since that discussion started more than half a year ago.)</p>



<a name="172229969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229969">(Aug 01 2019 at 15:16)</a>:</h4>
<p>so this is basically "UB for forwards-compatibility"</p>



<a name="172229990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172229990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172229990">(Aug 01 2019 at 15:16)</a>:</h4>
<p>which is unlike e.g. <code>let x: bool = mem::uninitialized()</code> which is UB "for real" and <em>does</em> already cause problems and there is no intention to make this defined.</p>



<a name="172230774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172230774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172230774">(Aug 01 2019 at 15:26)</a>:</h4>
<p>I think that when sending PRs to libraries, you better make sure that the things are "hard" UB if they are not super clearly specified yet - for num_cpus, one needs to inspect the types involved, and see if they use <code>bool</code>, or <code>fn</code> or <code>&amp;T</code>, and based on that make an assesment</p>



<a name="172230788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172230788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172230788">(Aug 01 2019 at 15:26)</a>:</h4>
<p>at least until the specification advances a bit</p>



<a name="172263316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172263316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172263316">(Aug 01 2019 at 21:28)</a>:</h4>
<blockquote>
<p>I think we should start by linting (for both uninitialized and zeroed) for types that don't allow the all-0 bit pattern -- i.e., references, NonNull, NonZero*, fn. That's definitely UB, and it has already repeatedly caused issues in practice.</p>
</blockquote>
<p>PRs welcome <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="172263881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172263881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172263881">(Aug 01 2019 at 21:36)</a>:</h4>
<p>time machines welcome ;)</p>



<a name="172264044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit%20and%20FFI/near/172264044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/MaybeUninit.20and.20FFI.html#172264044">(Aug 01 2019 at 21:38)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span>  I don't mean from you necessarily ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>